<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>demo Test</title>
<script>
function dotxtout(s)
{
	txtout.value+=s+"\r\n";
	txtout.scrollTop=txtout.scrollHeight;
}

window.onerror=function(){
	arglen=arguments.length;   
    var errorMsg="参数个数："+arglen+"个";   
    for(var i=0;i<arglen;i++){   
		errorMsg+="\n参数"+(i+1)+"："+arguments[i];
	}
	dotxtout(errorMsg);
}

window.APP_CALL=Object.create({
		formHDs: new Array(),/*创建子窗体的句柄*/
		formHDIndex: 0,
		/////////////////////[触发事件回调]/////////////////////////
		onFocus:function(){},/*当前窗口失去焦点,触发此函数*/
		onLoseFocus:function(){},/*当前窗口获得焦点,触发此函数*/
		onShow:function(){},/*当前窗口被显示时,触发此函数*/
		onHide:function(){},/*当前窗口被隐藏时,触发此函数*/
		onClose:function(){},/*当前窗口被关闭时,触发此函数*/
		onFormShow:function(HD){},/*子窗口被显示时,触发此函数*/
		onFormClose:function(HD){},/*子窗口被关闭时,触发此函数*/
		onFormHide:function(HD){},/*子窗口被隐藏时,触发此函数*/
		onNewUrl:function(HD){},/*子窗口打开链接时,触发此函数*/
		onLoadComplete:function(HD){},/*子窗口加载完成时,触发此函数*/
		/////////////////////[当前窗口控制]/////////////////////////
		GetThisHD: function() {/*获取当前窗口句柄*/
			return APP_GetThisHD();
		},
		GetParentHD: function() {/*获取父窗口句柄*/
			return APP_GetParentHD();
		},
		OnTaskBar: function(b) {/*显示或隐藏任务栏*/
			return APP_OnTaskBar(b);
		},
		closeForm: function() {/*关闭当前窗口, 主窗体关闭时为退出程序*/
			APP_closeForm();
		},
		hideForm: function() {/*隐藏当前窗口*/
			APP_hideForm();
		},
		resizeForm: function(w,h) {/*调整当前窗口长宽*/
			APP_resizeForm(w,h);
		},
		moveForm: function(x,y) {/*移动当前窗口位置*/
			APP_moveForm(x,y);
		},
		GetScreenWH: function() {/*获取桌面长宽*/
			tmpWHint=APP_GetScreenWH().split(',');
			tmpWHint[0]=parseInt(tmpWHint[0]);
			tmpWHint[1]=parseInt(tmpWHint[1]);
			return tmpWHint;
		},
		GetClipbrd: function() {/*获取剪切板文本*/
			tmpWH=APP_GetClipbrd();
			return tmpWH?tmpWH:'';
		},
		SetClipbrd: function(s) {/*复制文本到剪切板, 有编码问题, 建议不要使用*/
			return APP_SetClipbrd(s);
		},
		///////////////[控制指定HD(句柄)的窗口]////////////////
		//主窗口的HD为0
		newForm: function() {/*创建新窗体*/
			var tmpHD=parseInt(APP_newForm());
			this.formHDs[this.formHDIndex]=Object.create({
				formHD:tmpHD,
			});
			return tmpHD;
		},
		newTopForm: function() {/*创建新置顶窗体*/
			var tmpHD=parseInt(APP_newTopForm());
			this.formHDs[this.formHDIndex]=Object.create({
				formHD:tmpHD,
			});
			return tmpHD;
		},
		WinExec: function(c,s) {/*执行系统命令*/
			return APP_WinExec(c,s);
		},
		FormLoadFile: function(HD,f) {/*指定句柄窗体加载html文件*/
			return HD+1>1?APP_Form_LoadFile(HD,f):false;
		},
		FormLoadURL: function(HD,u) {/*指定句柄窗体加载url地址*/
			return HD+1>1?APP_Form_LoadURL(HD,u):false;
		},
		FormLoadHTML: function(HD,c) {/*指定句柄窗体加载html代码*/
			return HD+1>1?APP_Form_LoadHTML(HD,c):false;
		},
		FormsetWH: function(HD,w,h) {/*设置指定句柄窗体长宽*/
			return HD+1>1?APP_Form_setWH(HD,w,h):false;
		},
		FormsetMv: function(HD,x,y,w,h) {/*设置指定句柄窗体可被鼠标拖动窗口的区域*/
			return APP_Form_setMv(HD,x,y,w,h);
		},
		FormFormShow: function(HD,b) {/*显示或隐藏指定句柄窗体,传入值b为布尔值*/
			return APP_Form_FormShow(HD,b);
		},
		SetAppTitle: function(t) {/*设置任务栏显示title*/
			return APP_SetAppTitle(t);
		},
		FormsetUserAgent: function(HD,u) {/*设置指定句柄窗体的UserAgent, 可随时更改, 实时生效*/
			return HD+1>1?APP_Form_setUserAgent(HD,u):false;
		},
		FormClose: function(HD) {/*关闭指定句柄窗体*/
			return HD+1>1?APP_Form_close(HD):false;
		},
		FormSetOnTop: function(HD) {/*指定句柄窗体始终保持最顶端*/
			return APP_Form_SetOnTop(HD);
		},
		FormMove: function(HD,x,y) {/*移动指定句柄窗体*/
			return HD+1>1?APP_Form_Move(HD,x,y):false;
		},
		FormRunjs: function(HD,s) {/*注入指定句柄窗体javascript环境执行js代码*/
			return HD+1>1?APP_Form_RunJS(HD,s):false;
		},
		FormRunjsPlus: function(HD,s) {/*同上*/
			return HD+1>1?APP_Form_RunJSPlus(HD,s):false;
		},
		FormGetXY: function(HD) {/*获取指定句柄窗体坐标位置*/
			tmpWHint=APP_Form_GetXY(HD).split(',');
			tmpWHint[0]=parseInt(tmpWHint[0]);
			tmpWHint[1]=parseInt(tmpWHint[1]);
			return tmpWHint;
		},
		FormHide: function(HD) {/*隐藏指定句柄窗体*/
			return HD+1>1?APP_Form_FormHide(HD):false;
		},
		Form_FormSCCPD: function(HD,id) {/*下面5个函数的公共封装*/
			return APP_Form_FormSCCPD(HD,id);
		},
		Form_SelectAll: function(HD) {/*指定句柄窗体快捷键, Ctrl+A*/
			return this.Form_FormSCCPD(HD,1);
		},
		Form_Copy: function(HD) {/*指定句柄窗体快捷键, Ctrl+C*/
			return this.Form_FormSCCPD(HD,2);
		},
		Form_Cut: function(HD) {/*指定句柄窗体快捷键, Ctrl+X*/
			return this.Form_FormSCCPD(HD,3);
		},
		Form_Paste: function(HD) {/*指定句柄窗体快捷键, Ctrl+V*/
			return this.Form_FormSCCPD(HD,4);
		},
		Form_Delete: function(HD) {/*指定句柄窗体快捷键, Delete*/
			return this.Form_FormSCCPD(HD,5);
		},
});

var testHD=0;

function newform()
{
	testHD=APP_CALL.newForm();
	APP_CALL.FormsetUserAgent(testHD,"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36");
	APP_CALL.FormsetMv(testHD, 0, 0, 730, 100);
	APP_CALL.FormsetWH(testHD,1024, 800);
	//APP_CALL.FormLoadFile(testHD,"demo.html");
	APP_CALL.FormLoadURL(testHD,"http://fm.baidu.com/");
	//APP_CALL.FormLoadURL(testHD,"http://y.qq.com/");
	
}


function jh()
{
	if(testHD != 0)
	{
		setTimeout("APP_CALL.FormRunjs(testHD,'xxoo=document.getElementsByClassName(\"sort-guide\")[0];xxoo.parentNode.removeChild(xxoo)')",5000);
		//APP_CALL.FormRunjs(testHD,'xxoo=document.getElementById("right-ads");xxoo.parentNode.removeChild(xxoo);');
		//APP_CALL.FormRunjs(testHD,'$(\'.fm-userbar\')[0].innerHTML=\'<input type="submit" value="mini播放器" onclick="APP_hideForm()" title="mini播放器"><input type="submit" value="关闭" onclick="APP_closeForm()" title="关闭">\'');
		//APP_CALL.FormRunjs(testHD,);
	}
}

window.APP_CALL.onFormClose=function(HD)
{
	HD=parseInt(HD);
	APP_CALL.closeForm();
}

var miniHD=0;
window.APP_CALL.onLoadComplete=function(HD)
{
	HD=parseInt(HD);
	if(HD!=0)
	{
		if(HD==testHD)
		{
			dotxtout(HD+'加载完成'+window.location.href+' '+window.location.pathname);
			jh();
			APP_CALL.FormFormShow(HD,true);
			//APP_CALL.FormMove(HD,0, 0);
			window.APP_CALL.FormRunjs(miniHD,'window.testHD='+testHD+';getimgname()');
			window.APP_CALL.FormRunjs(HD,'window.miniHD='+miniHD);
			
			//window.btoa(str)
			//window.atob("amF2YXNjcmlwdA==")
			
			//dotxtout(encodeURIComponent(hijackcode.value));
			dotxtout('ok');
			window.APP_CALL.FormRunjs(HD,hijackcode.value);
			//window.APP_CALL.FormRunjs(miniHD,"$('.yuzhong')[0].getElementsByTagName('li')[2].click()");
		}
		if(HD==miniHD)
		{
			dotxtout(miniHD+'加载完成');
			if(APP_CALL.GetThisHD()==0) newform();
			dotxtout(window.APP_CALL.FormSetOnTop(miniHD));
		}
	}
};

window.APP_CALL.onFormShow=function(HD)
{
	if(HD!=0 && HD==miniHD)
	{
		dotxtout(HD+'显示');
		APP_CALL.FormMove(miniHD,window.screen.availWidth-500, window.screen.availHeight-160);
	}
}

function maininit()
{
	APP_CALL.FormsetMv(0, 0, 0, 400, 150);
	APP_CALL.resizeForm(400,600);
	//APP_CALL.FormFormShow(0,true);//注释掉可隐藏调试窗口
	APP_CALL.FormSetOnTop(0);
	if(miniHD==0)
	{
		miniHD=APP_CALL.newTopForm();
		window.APP_CALL.FormSetOnTop(miniHD);
		//window.APP_CALL.FormMove(miniHD, window.screen.width-500, window.screen.height-160);
		dotxtout(window.screen.width+','+window.screen.height);
		//APP_CALL.FormMove(miniHD,window.screen.width-500, window.screen.height-160);
		APP_CALL.FormsetUserAgent(miniHD,"test 1.0");
		APP_CALL.FormsetMv(miniHD, 0, 0, 1, 0);
		APP_CALL.FormsetWH(miniHD, 500,160);
		APP_CALL.FormLoadFile(miniHD,"mini.html");
		//s += " 屏幕分辨率的高："+ window.screen.height+"\n";    
		//s += " 屏幕分辨率的宽："+ window.screen.width+"\n"; 
	}
}

function newminiform()
{
	APP_CALL.FormFormShow(miniHD,true);
}

window.APP_CALL.onFormHide=function(HD)
{
	HD=parseInt(HD);
	if(HD>0)
	{
		if(testHD==HD)
		{
			window.APP_CALL.OnTaskBar(false);
			newminiform();
		}
		if(miniHD==HD)
		{
			window.APP_CALL.OnTaskBar(true);
		}
	}
};

</script>
<head>
<body style='background: '>
<textarea id="txtout" rows="8" cols="10" style="resize:none;width: 100%;">
</textarea>
<script>
window.APP_CALL.OnTaskBar(true);
maininit();
window.APP_CALL.SetAppTitle('百度音乐随心听');

function jsdebug()
{
	APP_CALL.FormRunjsPlus(testHD,"firebug=document.createElement('script');firebug.setAttribute('src','http://getfirebug.com/releases/lite/1.2/firebug-lite.js');document.body.appendChild(firebug);(function(){if(window.firebug.version){firebug.init();}else{setTimeout(arguments.callee);}})();void(firebug);this.style.display='none';");
}
</script>
<input type="submit" value="随心听" onclick='jh()'>
<input type="submit" value="jsdebug" onclick='jsdebug()'>
<input type="submit" value="mini" onclick='newminiform()'>
<input type="submit" value="OnTaskBar" onclick='window.APP_CALL.OnTaskBar(true)'>
<input type="submit" value="OutTaskBar" onclick='window.APP_CALL.OnTaskBar(false)'>
<input type="submit" value="退出" onclick='APP_CALL.closeForm()' style="float:right">
<input type="submit" value="隐藏" onclick='APP_CALL.hideForm()' style="float:right">
<textarea id="hijackcode" rows="10" cols="10" style="resize:none;width: 100%;">
try { 
	xxoo=document.getElementById("right-ads");
	xxoo.parentNode.removeChild(xxoo);
}catch(e){}

$("body").css({"background-color":"transparent"});
$("#fm-panel").css({
"border": "solid 1px #b7b7b7",
"padding": ".2em 1em .275em",
"border-radius": "1em",
"box-shadow": "0 1px 2px rgba(0,0,0,.2)"
});

$('.fm-userbar')[0].innerHTML='<input id="minicall" type="submit" value="mini播放器" onclick="window.APP_CALL.OnTaskBar(false);APP_hideForm()" title="mini播放器"><input type="submit" value="关闭" onclick="APP_closeForm()" title="关闭">';



window.FormRunjs=function(HD,s){
	APP_Form_RunJS(HD,s)
};

window.APP_CALL=Object.create({formHDs:new Array,formHDIndex:0,onFocus:function(){},onLoseFocus:function(){},onShow:function(){},onHide:function(){},onClose:function(){},onFormShow:function(){},onFormClose:function(){},onFormHide:function(){},onNewUrl:function(){},onLoadComplete:function(){},GetThisHD:function(){return APP_GetThisHD()},GetParentHD:function(){return APP_GetParentHD()},OnTaskBar:function(a){return APP_OnTaskBar(a)},closeForm:function(){APP_closeForm()},hideForm:function(){APP_hideForm()},resizeForm:function(a,b){APP_resizeForm(a,b)},moveForm:function(a,b){APP_moveForm(a,b)},GetScreenWH:function(){return tmpWHint=APP_GetScreenWH().split(","),tmpWHint[0]=parseInt(tmpWHint[0]),tmpWHint[1]=parseInt(tmpWHint[1]),tmpWHint},GetClipbrd:function(){return tmpWH=APP_GetClipbrd(),tmpWH?tmpWH:""},SetClipbrd:function(a){return APP_SetClipbrd(a)},newForm:function(){var a=parseInt(APP_newForm());return this.formHDs[this.formHDIndex]=Object.create({formHD:a}),a},newTopForm:function(){var a=parseInt(APP_newTopForm());return this.formHDs[this.formHDIndex]=Object.create({formHD:a}),a},FormLoadFile:function(a,b){return a+1>1?APP_Form_LoadFile(a,b):!1},FormLoadURL:function(a,b){return a+1>1?APP_Form_LoadURL(a,b):!1},FormLoadHTML:function(a,b){return a+1>1?APP_Form_LoadHTML(a,b):!1},FormsetWH:function(a,b,c){return a+1>1?APP_Form_setWH(a,b,c):!1},FormsetMv:function(a,b,c,d,e){return APP_Form_setMv(a,b,c,d,e)},FormFormShow:function(a,b){return APP_Form_FormShow(a,b)},SetAppTitle:function(a){return APP_SetAppTitle(a)},FormsetUserAgent:function(a,b){return a+1>1?APP_Form_setUserAgent(a,b):!1},FormClose:function(a){return a+1>1?APP_Form_close(a):!1},FormSetOnTop:function(a){return APP_Form_SetOnTop(a)},FormMove:function(a,b,c){return a+1>1?APP_Form_Move(a,b,c):!1},FormRunjs:function(a,b){return a+1>1?APP_Form_RunJS(a,b):!1},FormRunjsPlus:function(a,b){return a+1>1?APP_Form_RunJSPlus(a,b):!1},FormGetXY:function(a){return tmpWHint=APP_Form_GetXY(a).split(","),tmpWHint[0]=parseInt(tmpWHint[0]),tmpWHint[1]=parseInt(tmpWHint[1]),tmpWHint},FormHide:function(a){return a+1>1?APP_Form_FormHide(a):!1},Form_FormSCCPD:function(a,b){return APP_Form_FormSCCPD(a,b)},Form_SelectAll:function(a){return this.Form_FormSCCPD(a,1)},Form_Copy:function(a){return this.Form_FormSCCPD(a,2)},Form_Cut:function(a){return this.Form_FormSCCPD(a,3)},Form_Paste:function(a){return this.Form_FormSCCPD(a,4)},Form_Delete:function(a){return this.Form_FormSCCPD(a,5)}});

player.playx=player.play;
player.play=function(){
	player.playx();
	//window.APP_CALL.FormRunjs(window.miniHD,'getimgname()');
}
$('.fm-album')[0].getElementsByTagName('img')[0].onload=function(){
	window.APP_CALL.FormRunjs(window.miniHD,'getimgname()');
}
if(player.getState() == "playing")
{
	window.APP_CALL.FormRunjs(window.miniHD,'btnplay.style.display="block";btnpause.style.display="none"');
}else{
	window.APP_CALL.FormRunjs(window.miniHD,'btnplay.style.display="none";btnpause.style.display="block"');
}
window.lastlrc='';
function syncLrc()
{
	tt=$('.ui-lrc-current')[0].innerHTML;
	if(window.lastlrc != tt)
	{
		window.APP_CALL.FormRunjs(window.miniHD,'lrcsw.innerHTML="'+tt+'"');
		window.lastlrc = tt;
	}
}
setInterval("syncLrc()",200);

minicall.value="mini播放器!";

</textarea>
</body>
</html>




